﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;
namespace Server_NhaSach.BusinessLayer
{
    public class PhieuTraHangNCCBlo
    {
        #region "Khai báo các biến"
        private PhieuTraHangNCCDAO da;
        private PhieuTraHangNCCDTO _CTDHNCC;
        private string _error;
        #endregion

        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public PhieuTraHangNCCDTO CTDHNCC
        {
            get { return _CTDHNCC; }
            set { _CTDHNCC = value; }
        }
        #endregion

        #region "Khai báo các Method"
        public PhieuTraHangNCCBlo()
        {
            _CTDHNCC = new PhieuTraHangNCCDTO();
            da = new PhieuTraHangNCCDAO();
        }
        public bool InsertPhieuTraHangNCC(string maTHNCC, string maNV, string maKho, string maNCC, string maSoThue, DateTime ngayTra, string nguoiTra, string chungTuTra, string ghiChuTH, double tongThanhTien)
        {
            CTDHNCC = new PhieuTraHangNCCDTO(maTHNCC,  maNV, maKho, maNCC, maSoThue, ngayTra, nguoiTra, chungTuTra, ghiChuTH, tongThanhTien);
            if (!da.InsertPTHNCC(CTDHNCC))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        
        public bool DeletePhieuTraHangNCC(string MaTHNCC)
        {
            if (!da.DeletePTHNCC(MaTHNCC))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_PhieuTraHangNCC()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_PhieuTraHangNCC();
            return ds;
        }

        public bool UpdatePhieuTraHangNCC(string maTHNCC, string maNV, string maKho, string maNCC, string maSoThue, DateTime ngayTra, string nguoiTra, string chungTuTra, string ghiChuTH, double tongThanhTien)
        {
            CTDHNCC = new PhieuTraHangNCCDTO(maTHNCC, maNV, maKho, maNCC, maSoThue, ngayTra, nguoiTra, chungTuTra, ghiChuTH, tongThanhTien);
            if (!da.UpdatePTHNCC(CTDHNCC))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        #endregion
    }
}